﻿namespace Arms.Framework
{
    using System;
    using System.Text;

    public static class GuidExtensions
    {
        /// <summary>
        /// Converts a GUID to ASCII values 0-9 and A-F 20 characters long.
        /// </summary>
        /// <param name="guid"></param>
        /// <returns>Shortened 32 byte string</returns>
        public static string ToShortGuidString(this Guid guid)
        {
            StringBuilder sb = new StringBuilder();

            foreach (byte b in guid.ToByteArray())
            {
                sb.Append(string.Format("{0:X2}", b));
            }

            return sb.ToString();
        }
    }
}
